import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'
import LoginView from "@/views/auth/LoginView.vue";
import Layout from "@/views/Layout.vue";
import UserView from "@/views/UserView.vue";
import ShowView from "@/views/ShowView.vue";
import PwScoreView from '@/views/pw/PwScoreView.vue';
import BsScoreView from '@/views/BsScoreView.vue';
import XsScoreView from '@/views/XsScoreView.vue';
import Login2 from '@/views/auth/login2.vue';
import Show2 from '@/views/show2.vue';
import DaoJiShi from '@/views/DaoJiShi.vue';
import RegisterView from '@/views/auth/RegisterView.vue';
import ScoreCardView from '@/components/ScoreCardView.vue';
import Judgescore from '@/views/Judgescore.vue';
import Playerscore from '@/views/Playerscore.vue';
import Matchscore from '@/views/Matchscore.vue';
import Ruanyuescore from '@/views/Ruanyuescore.vue';
import Recordscore from '@/views/Recordscore.vue';
import Dafen from '@/views/Dafen.vue';
import ShowScore from '@/views/ShowScore.vue';
import OrderByScore from '@/views/OrderByScore.vue';
import PwShow from '@/views/pw/PwShow.vue';

/* import StaticHtmlPage from '@/views/StaticHtmlPage.vue'; */


Vue.use(VueRouter)

const routes = [
  /* {
     path: 'static-html-page',
     name: 'StaticHtmlPage',
     component: () => import('@/views/StaticHtmlPage.vue')
  }, */
  {
    path: '/pwshow',
    name: 'pwshow',
    component: PwShow,
  },
  {
    path: '/login',
    name: 'login',
    component: LoginView,
  },
  {
    path: '/register',
    name: 'register',
    component: RegisterView,
  },

  {
    path: '/bsscore',
    name: 'BsScore',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: BsScoreView
  },
  {
    path: '/',
    name: 'dafen',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: Dafen
  }
  ,
  {
    path: '/showscore',
    name: 'showscore',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: ShowScore
  },
  ,
  {
    path: '/orderbyscore',
    name: 'orderbyscore',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: OrderByScore
  },
  {
    path: '/show',
    name: 'Show',
    component: ShowView,
  },
  {
    path: '/score',
    name: 'score',
    component: ScoreCardView,
  },
  {
    path: '/DaoJiShi',
    name: 'DaoJiShi',
    component: DaoJiShi,
  },
  {
    path: '/show2',
    name: 'Show2',
    component: Show2,
  }
  ,
  {
    path: '/login2',
    name: 'Login2',
    component: Login2,
  },
  {
    path: '/xsscore',
    name: 'XsScore',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: XsScoreView
  },
  {
    path: '/user',
    name: 'user',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: UserView
  },
  {
    path: '/layout',
    name: 'Layout',
    component: Layout,
    /*redirect: 'home',覆盖*/
    children: [
      {
        path: '/',
        name: 'Home',
        component: HomeView
      },
      {
        path: '/judge',
        name: 'Judge',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: Judgescore
      },
      {
        path: '/ruanyue',
        name: 'ruanyue',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: Ruanyuescore
      }
      ,
      {
        path: '/record',
        name: 'record',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: Recordscore
      },
      {
        path: '/player',
        name: 'player',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: Playerscore
      },
      {
        path: '/pwscore',
        name: 'PwScore',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: PwScoreView
      }
      ,
      {
        path: '/match/:acid',
        name: 'match',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: Matchscore
      }
    ]
  },
]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})

// 路由守卫
// router.beforeEach((to, from, next) => {
//   // if(to.path === '/login' ) {
//   //   next();

//   // }
//   const user = localStorage.getItem("user");
//   if (!user) {
//     // return next('/login');
//     location.href = "/";
//   } else {
//     next();
//   }
// })

export default router
